#include <bits/stdc++.h>
using namespace std;
#define LMAX 1000005
#define N 100005
int t, n, m, L, V, ans1, ans2, cnt, cf[LMAX], p[N], d[N], v[N], a[N];
struct Node {
    int l, r, num;;
} node[N];
bool cmp(Node n1, Node n2) {
    return n1.l < n2.l;
}
vector<int> e;
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &t);
    while(t--) {
        scanf("%d%d%d%d", &n, &m, &L, &V);
        memset(cf, 0, sizeof(cf)); ans1 = 0, ans2 = 0, cnt = 0;
        e.clear();
        for (int i = 1; i <= n; i++) {
            scanf("%d%d%d", &d[i], &v[i], &a[i]);
        }
        for (int i = 1; i <= m; i++) {
            scanf("%d", &p[i]);
        }
        for (int i = 1; i <= n; i++) {
            if (a[i] == 0) {
                if (v[i] > V) {
                    cf[d[i]]++;
                    node[++cnt].l = d[i];
                    node[cnt].r = L;
                    node[cnt].num = i;
                }
            }
            else if (a[i] < 0) {
                if (v[i] > V) {
                    long double tt = (long double)(v[i]-V)/(long double)(-a[i]);
                    long double x = d[i]+v[i]*tt+0.5*((long double)a[i])*tt*tt-0.0000001;
                    int y = x;
                    node[++cnt].l = d[i];
                    node[cnt].r = y;
                    node[cnt].num = i;
                }
            }
            else {
                if (v[i] > V) {
                    node[++cnt].l = d[i];
                    node[cnt].r = L;
                    node[cnt].num = i;
                    cf[d[i]]++;
                }
                else {
                    long double tt = (long double)(V-v[i])/(long double)a[i];
                    long double x = d[i]+v[i]*tt+0.5*((long double)a[i])*tt*tt+(long double)0.9999999999999999999;
                    int y = x;
                    if (y <= L) {
                        node[++cnt].l = y;
                        node[cnt].r = L;
                        node[cnt].num = i;
                        cf[y]++;
                    }
                }
                
            }
        }
        sort(node+1, node+cnt+1, cmp);
        sort(p+1, p+m+1);
        for (int i = 1; i <= L; i++) {
            cf[i] += cf[i-1];
        }
        ans1 = cf[p[m]];
        ans2 = m-1;
        printf("%d %d\n", ans1, ans2);
    }
    return 0;
}